<template>
  <div>
    <template v-for="(item,index) in sideBarData">
      <!-- 标题 -->
      <template v-if="item.children.length">
        <el-submenu :key="index" :index="item.index">
          <template :index="item.index" slot="title">
            <i :class="item.icon"></i>
            <span>{{item.name}}</span>
          </template>
          <el-menu-item-group>
            <sideBar :list="item.children"></sideBar>
          </el-menu-item-group>
        </el-submenu>
      </template>
      <!-- 选项 -->
      <template v-else>
        <el-menu-item :key="index" :index="item.index">
          <i :class="item.icon"></i>
          <span>{{item.name}}</span>
        </el-menu-item>
      </template>
    </template>
  </div>
</template>
<script>
export default {
  name: "menuItem",
  props: {
    list: Array
  },
   data(){
    return{
      sideBarData: [
  {
    name: "菜单1",
    index: "menu1",
    icon: "el-icon-menu",
    children: [
      {
        name: "菜单1-1",
        index: "menu1-1",
        icon: "el-icon-menu",
        children: [
          {
            name: "菜单1-1-1",
            index: "menu1-1-1",
            icon: "el-icon-menu",
            children: []
          },
          {
            name: "菜单1-1-2",
            index: "menu1-1-2",
            icon: "el-icon-menu",
            children: []
          }
        ]
      },
      {
        name: "菜单1-2",
        index: "menu1-2",
        icon: "el-icon-menu",
        children: []
      }
    ]
  },
  {
    name: "菜单2",
    index: "menu2",
    icon: "el-icon-document-copy",
    children: [
      {
        name: "数据集管理2",
        index: "dataset2",
        icon: "el-icon-document-copy",
        children: []
      },
    ]
  },
  {
    name: "菜单2",
    index: "menu3",
    icon: "el-icon-folder",
    children: []
  }
]
    }
  },
};
</script>
<style>

</style>